package com.authine.cloudpivot.ext.vo.zhende.receipt;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.xml.bind.annotation.*;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = {
    "header",
    "body"
})
@XmlRootElement(name = "soapenv:Envelope")
@Data
@AllArgsConstructor
@NoArgsConstructor
public class EnvelopeReceipt {

    @XmlAttribute(name="xmlns:soapenv")
    private String soapenv="http://schemas.xmlsoap.org/soap/envelope/";
    @XmlAttribute(name="xmlns:s4")
    private String eapp="http://ZDSAP.COM/S4";

    @XmlElement(name = "soapenv:Header", required = true)
    protected Header header;
    @XmlElement(name = "soapenv:Body", required = true)
    protected Body body;

    public EnvelopeReceipt(Header header, Body body) {
        this.header = header;
        this.body = body;
    }

    public static EnvelopeReceipt toXml(String itemNumber) {

        return new EnvelopeReceipt(new Header(),Body.builder()
                .mt1210MMPURCHASERECINFOREQ(MT1210MMPURCHASERECINFOREQ.builder()
                        .ivzebeln(itemNumber)
                        .build())
                .build());
    }
}
